import "./assets/main.scss";

// 导入所有 element 样式
import "element-plus/dist/index.css";

import { createApp } from "vue";
import { createPinia } from "pinia";
import ElementPlus from "element-plus";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import App from "./App.vue";
import router from "./router";
import { setupRouterGuard } from "./router/guard";
import { configNProgress } from "./utils/nprogress";
import { useUserStore } from "./stores/user";

const app = createApp(App);

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

app.use(createPinia());
app.use(router);

// 配置页面加载进度条
configNProgress();
// 加载用户缓存信息
useUserStore().setLoginStatusAsync();
// 设置路由守卫
setupRouterGuard(router);

// 使用 Element 组件
app.use(ElementPlus);

app.mount("#app");
